/**
 * Created by bianlian on 2018/4/19.
 */
var nodeExcel = require('excel-export');
// const xx = require('./styles.xml');
exports.getList = async(ctx) => {
    var conf ={};
    // uncomment it for style example
    // conf.stylesXmlFile = "./styles.xml";
    conf.name = "111";//表格名
    //定义表格列字段
    conf.cols = [
        {
            caption:'id',
            type:'number',
            width:28.7109375
        },
        {
            caption:'date',
            type:'string'
        },
        {
            caption:'time',
            type:'string'
        },
        {
            caption:'uid',
            type:'number'
        },
        {
            caption:'mobile',
            type:'string',
            width:80
        },
        {
            caption:'name',
            type:'string'
        },
        {
            caption:'roleName',
            type:'string'
        },
        {
            caption:'vid',
            type:'number'
        },
        {
            caption:'vendorName',
            type:'string'
        },
        {
            caption:'systemType',
            type:'number'
        },
        {
            caption:'eventTag',
            type:'string',
            width:80
        },
        {
            caption:'desc',
            type:'string',
            width:120
        },
        {
            caption:'ip',
            type:'string'
        }
    ];
    //填充表格数据
    conf.rows = [
        [9,'2016-06-20','16:22:31',1504,'13000000006','呵呵','店长',56,'美容护肤',2,'订单管理','获取订单详情','127.0.0.1'],
        [8,'2016-06-20','16:22:31',1504,'13000000006','呵呵','店长',56,'美容护肤',2,'订单管理','获取订单列表','192.168.145.162'],
    ];
    var result = nodeExcel.execute(conf);
    ctx.set('Content-Type', 'application/vnd.openxmlformats');
    ctx.set("Content-Disposition", "attachment; filename=" + "o2olog.xlsx");
    // ctx.response.header = Object.assign({},ctx.response.header, {'Content-Type':'application/vnd.openxmlformats'},{"Content-Disposition": "attachment; filename=" + "Report.xlsx"})
    // ctx.response.end(result, 'binary');
    let data = new Buffer(result,'binary');
    ctx.body = data;
};

